@use 'sass:map';
@use 'sass:color';
@use '@angular/material' as mat;
@use './entity/entity-theme' as entity;
@use './dimension/dimension-theme' as dimension;
@use './query-lab/query-lab-theme' as query-lab;

@mixin color($config-or-theme) {
  $config: mat.get-color-config($config-or-theme);
  $background: map.get($config, background);
  $foreground: map.get($config, foreground);
  $primary: map.get($config, primary);
  $accent: map.get($config, accent);
  $warn: map.get($config, warn);

  @include entity.color($config-or-theme);
  @include dimension.color($config-or-theme);
  @include query-lab.color($config-or-theme);

  .pac-model__nav-list {

    .mat-mdc-list-item.selected {
      background-color: mat.get-color-from-palette($background, 'focused-button');
    }
    .mat-mdc-list-item:hover {
      background-color: color.change(mat.get-color-from-palette($primary), $alpha: 0.1);
      color: mat.get-color-from-palette($primary);
    }

    .pac-model__nav-icon {
      margin-right: 5px;
      flex-shrink: 0;
    }

    .mat-mdc-list-item-content {
      overflow: hidden;
    }

    .mat-mdc-list-item-unscoped-content {
      @apply flex items-center;
    }
  }

  .ngm-semanctic-model {
    .pac-model__shell-bar.mat-toolbar {
      height: unset;
      font-size: 1rem;

      .mat-button {
        min-width: unset;
        border-radius: 0;
        &.mat-accent {
          .mat-button-ripple {
            background-color: color.change(mat.get-color-from-palette($accent), $alpha: 0.1);
          }
        }
      }

      .content {
        font-size: 0.85rem;
      }
    }

    .pac-model__tables-viewport {
      .cdk-virtual-scroll-content-wrapper {
        max-width: 100%;
      }
    }

    .pac-cdk-drop-list-dragging {
      border: 1px dashed transparent;
      &.cdk-drop-list-dragging {
        border-color: mat.get-color-from-palette($accent);
      }
    }
  }

  // Style for DropList
  .pac-cdk-drop__list.cdk-drop-list {
    position: relative;
    
    &::after {
      content: "";
      position: absolute;
      top: 0px;
      bottom: 0;
      left: 0;
      right: 0;
      z-index: 100;
      opacity: 0;
      box-shadow: 0 0 mat.get-color-from-palette($accent) inset;
      pointer-events: none;
      transition: all .2s;
    }

    &.cdk-drop-list-receiving::after {
      opacity: 1;
      box-shadow: 0 0 5px 1px mat.get-color-from-palette($accent) inset;
    }
    &.cdk-drop-list-dragging::after {
      opacity: 1;
      box-shadow: 0 0 8px 3px mat.get-color-from-palette($accent) inset;
    }

    .cdk-drag-placeholder {
      border: dotted 3px mat.get-color-from-palette($primary);
      min-height: 30px;
      transition: transform 250ms cubic-bezier(0, 0, 0.2, 1);
    }
  }

  .pac-cdk-drop__area.cdk-drop-list {
    .cdk-drag-placeholder {
      display: none;
    }
  }

  .cdk-drag-preview {
    display: flex;
    box-sizing: border-box;
    border-radius: 4px;
    box-shadow: 0 5px 5px -3px rgba(0, 0, 0, 0.2),
                0 8px 10px 1px rgba(0, 0, 0, 0.14),
                0 3px 14px 2px rgba(0, 0, 0, 0.12);

    .mat-mdc-list-item-content {
      flex: 1;
    }
  }
  .pac-cdk-drop__recycle-bin.mat-mdc-icon-button {
    opacity: 0;
    visibility: hidden;
    border: 1px dashed transparent;
    overflow: hidden;

    &.cdk-drop-list-receiving,
    &.cdk-drop-list-dragging {
      opacity: 1;
      visibility: visible;
    }
    &.cdk-drop-list-dragging {
      border-color: mat.get-color-from-palette($warn);
    }
  }

  .pac-badge-status-dot {
    background-color: mat.get-color-from-palette($accent);
    width: 8px;
    height: 8px;
    vertical-align: middle;
    border-radius: 50%;
  }

  .pac-model__sub-area {
    position: relative;
    .pac-model__sub-area-content {
      flex: 1;
      overflow: hidden;
      &:hover {
        overflow-y: auto;
      }
    }
  }

  .pac-model__accordion.mat-accordion {
    .mat-expansion-panel {
      border-radius: 1rem;
    }
    .mat-expansion-panel:first-of-type {
      border-top-right-radius: 1rem;
      border-top-left-radius: 1rem;
    }
    .mat-expansion-panel:last-of-type {
      border-bottom-right-radius: 1rem;
      border-bottom-left-radius: 1rem;
    }
    .mat-mdc-list-item {
      border-radius: 5px;

      &:hover {
        background-color: color.change(mat.get-color-from-palette($primary), $alpha: 0.1);
        .pac-nav-tab__close {
          opacity: 1;
        }
      }

      .pac-nav-tab__close {
        opacity: 0;
      }
    }
  }

  .pac-model-access-control {
    .pac-model-access__cubes {
      .ngm-entity-schema {
        .mat-tree {
          background: unset;
        }
        &.selected {
          background-color: color.change(mat.get-color-from-palette($primary), $alpha: 0.05);
        }

        .mat-tree-node.selected {
          background-color: color.change(mat.get-color-from-palette($primary), $alpha: 0.1);
        }
      }
    }
  }
}

@mixin density($config-or-theme) {
  @include entity.density($config-or-theme);
  @include dimension.density($config-or-theme);
  @include query-lab.density($config-or-theme);
}
